import $http from "@/services";

export default {
    state: {
        // 人数显示
        staffAmountLists: [],
        staffData: {},// 入职员工最久的十位
        pieList: [],//类型一致都是圆形 同一行 
        columnList: [],//树状图 员工年龄段 部门员工数量 员工平均年龄
        marriageData: {},//员工婚姻状态
        constellationData: {}//员工星座分布图
    },
    reducers: {
        setState(state, { payload }) {
            const defaultPayload = {
                ...state,
                staffAmountLists: [
                    { title: "总人数", styleData: { width: "100%", height: "170px" }, Number: payload.total },
                    { title: "入职一年人数", styleData: { width: "33%", height: "170px" }, Number: payload.onboardingTimeData.one },
                    { title: "入职1-2年人数", styleData: { width: "33%", height: "170px" }, Number: payload.onboardingTimeData.two },
                    { title: "入职3年以上人数", styleData: { width: "33%", height: "170px" }, Number: payload.onboardingTimeData.three },
                ],
                staffData: {
                    title: "工龄最老的十个人",
                    StyleData: { width: "49.7%", height: "350px" },
                    data: payload.wordingYearsMaps
                },
                pieList: [
                    {
                        title: "学历情况",
                        StyleData: { width: "49.7%", height: "350px" },
                        data: payload.educationList
                    },
                    {
                        title: "员工性别占比",
                        StyleData: { width: "49.7%", height: "350px" },
                        data: payload.genderList,
                        showSidebar: true,//是否展示其按钮
                    },
                ],
                columnList: [
                    {
                        title: "员工年龄段",
                        StyleData: { width: "49.7%", height: "350px" },
                        data: payload.ageMap
                    },
                    {
                        title: "员工部门数量",
                        StyleData: { width: "49.7%", height: "350px" },
                        data: payload.departmentList,
                        br: true
                    },
                ],
                marriageData: {
                    title: "员工婚姻状况",
                    StyleData: { width: "49.7%", height: "350px" },
                    data: payload.marriageList,
                    isEmpty: true
                },
                constellationData: {
                    title: "员工星座分布",
                    StyleData: { width: "49.7%", height: "350px" },
                    data: payload.constellationList,
                    isArea: true
                }

            }
            return { ...state, ...defaultPayload }
        }
    },
    effects: {
        *initDashboardList({ }, { call, put }) {
            const result = yield call($http.getAnalyzeStaff);
            yield put({
                type: "setState",
                payload: result.data
            });
        }
    }

}